package stub;

import java.io.FileInputStream;
import java.util.Properties;

/**
 * Manage Stub files for the classes from a propertie file.<br>
 * <br>
 * An entry in the propertie file exemple :<br>
 * MyClassFile=file.xxx<br>
 * 
 * @author pula1
 *
 */
public class StubPropreties {
	
	private static final String STUB_PROPERTIES_FILE = "properties/stub.properties";
	private static final String STUB_FILE 	= "StubFile";
	
	private static Properties p = new Properties();
	
	// First load of stub.properties file
	static {
		reload();
	}
	
	/**
	 * Reload the stub.properties file.
	 */
	public static void reload() {
		try {
			FileInputStream in = new FileInputStream(STUB_PROPERTIES_FILE);
			p.load(in);
			in.close();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Returns the file which contains the data for the Stub<br>
	 * by the name of the class the Stub is desingned for.
	 * 
	 * @param className The name of the class the Stub is desingned for.
	 * @return The path of the file
	 */
	public static String getFileByClassName(String className) {
		return p.getProperty(className + STUB_FILE);
	}
	
}
